
"""
@名称：练习
@作者：Fida1214
@日期：2025/4/9
"""

"""
第五题，种花
"""

import random

class Flower:
    def __init__(self, name, growth_time, beauty):
        self.name = name
        self.growth_time = growth_time
        self.beauty = beauty
        self.grown = False

    def grow(self):
        if random.randint(1, 10) <= self.growth_time:
            self.grown = True
            print(f"{self.name} 开花啦！它的美丽值是 {self.beauty}。")
        else:
            print(f"{self.name} 还在生长中...")

class Garden:
    def __init__(self, name):
        self.name = name
        self.flowers = []

    def plant_flower(self, flower):
        self.flowers.append(flower)
        print(f"在 {self.name} 种下了 {flower.name}。")

    def check_garden(self):
        for flower in self.flowers:
            flower.grow()

rose = Flower("玫瑰", 3, 8)
tulip = Flower("郁金香", 2, 7)

secret_garden = Garden("Fida的花园")

secret_garden.plant_flower(rose)
secret_garden.plant_flower(tulip)
for _ in range(20):
    secret_garden.check_garden()
